import list from "./list.json"
import detail from "./1.json"
import success from "../success.json"
import type {MockMethod} from "vite-plugin-mock";
import {findItemById} from "../utils";


export default [
    {
        url: "/dept/list",
        method: "post",
        response: ({query}: any) => {
            return list;
        }
    },
    {
        url: "/dept/detail",
        method: "get",
        response: ({query}: any) => {
            let info = findItemById(list.data, query.id, "deptId");
            let infoResult = null;
            if (info) {
                infoResult = JSON.parse(JSON.stringify(info));
                if (infoResult.children) {
                    infoResult.children = null;
                }
            }
            let result = JSON.parse(JSON.stringify(success));
            result.data = infoResult;
            return detail;
        }
    },
    {
        url: "/dept/delete/:id",
        method: "delete",
        response: ({query}: any) => {
            return success;
        }
    },
] as MockMethod[];
